import axios from 'axios'
import {useState, useEffect} from 'react'
import { API } from '../config'

export default function useGetCategories() {
    const [categories, setCategories] = useState([])
    useEffect(() => {
        async function getcategories () {
            let res = await axios.get(`${API}/categories`)
            setCategories(res.data)
        }
        getcategories()
    }, [])
    return categories
}